home *** CD-ROM | disk | FTP | other *** search
- library PasPush;
-
- {$R push.RES}
- {$D Micro System Solutions - MS VB3.0 Push Demo}
-
-
- uses wintypes, winprocs, vbapi_, strings;
-
-
- {//---------------------------------------------------------------------------
- // Resource ID's
- //---------------------------------------------------------------------------
- // Toolbox bitmap resource IDs.
- //---------------------------------------------------------------------------}
- const
- IDBMP_Push = 8000;
- IDBMP_PushDOWN = 8001;
- IDBMP_PushMONO = 8003;
- IDBMP_PushEGA = 8006;
-
- {//---------------------------------------------------------------------------
- // Standard Error Values
- //---------------------------------------------------------------------------}
- ERR_None = 0;
- ERR_InvPropVal = 380; {/ Error$(380) = "Invalid property value"}
-
-
- {//---------------------------------------------------------------------------
- // Procedure Declarations
- //---------------------------------------------------------------------------}
-
- {//---------------------------------------------------------------------------
- // Global Variables and Constants
- //---------------------------------------------------------------------------}
-
- {//---------------------------------------------------------------------------
- // Push control data and structs
- //---------------------------------------------------------------------------}
- type
- PPush = ^TPush;
- TPush = record
- AutoBeep: Bool;
- end;
-
- {//---------------------------------------------------------------------------
- // Property list
- //---------------------------------------------------------------------------
- // Define the consecutive indicies for the properties
- //---------------------------------------------------------------------------}
- const
- IPROP_Push_NAME = $0000;
- IPROP_Push_INDEX = $0001;
- IPROP_Push_PARENT = $0002;
- IPROP_Push_BACKCOLOR = $0003;
- IPROP_Push_LEFT = $0004;
- IPROP_Push_TOP = $0005;
- IPROP_Push_WIDTH = $0006;
- IPROP_Push_HEIGHT = $0007;
- IPROP_Push_ENABLED = $0008;
- IPROP_Push_VISIBLE = $0009;
- IPROP_Push_MOUSEPOINTER = $000A;
- IPROP_Push_CAPTION = $000B;
- IPROP_Push_FONTNAME = $000C;
- IPROP_Push_FONTSIZE = $000D;
- IPROP_Push_FONTBOLD = $000E;
- IPROP_Push_FONTITALIC = $000F;
- IPROP_Push_FONTSTRIKE = $0010;
- IPROP_Push_FONTUNDER = $0011;
- IPROP_Push_DRAG = $0012;
- IPROP_Push_DRAGICON = $0013;
- IPROP_Push_TABINDEX = $0014;
- IPROP_Push_TABSTOP = $0015;
- IPROP_Push_TAG = $0016;
- IPROP_Push_AutoBeep = $0017;
-
- AutoBeepName: array[0..8] of Char = 'AutoBeep'#0;
-
- Property_AutoBeep: tPROPINFO =
- (
- npszName: tOffset(@AutoBeepName);
- fl: DT_Bool or PF_fGetData or PF_fSetData or PF_fSaveData;
- offsetData: 0;
- infoData: 0;
- dataDefault: 0;
- npszEnumList: 0;
- enumMax: 0
- );
-
- const
- PropListPush : array[0..24]of ofsPPROPINFO =
- (
- pPROPInfo_STD_CTLNAME,
- PPROPINFO_STD_INDEX,
- PPROPINFO_STD_PARENT,
- PPROPINFO_STD_BACKCOLOR,
- PPROPINFO_STD_LEFT,
- PPROPINFO_STD_TOP,
- PPROPINFO_STD_WIDTH,
- PPROPINFO_STD_HEIGHT,
- PPROPINFO_STD_ENABLED,
- PPROPINFO_STD_VISIBLE,
- PPROPINFO_STD_MOUSEPOINTER,
- PPROPINFO_STD_CAPTION,
- PPROPINFO_STD_FONTNAME,
- PPROPINFO_STD_FONTSIZE,
- PPROPINFO_STD_FONTBOLD,
- PPROPINFO_STD_FONTITALIC,
- PPROPINFO_STD_FONTSTRIKE,
- PPROPINFO_STD_FONTUNDER,
- PPROPINFO_STD_DRAGMODE,
- PPROPINFO_STD_DRAGICON,
- PPROPINFO_STD_TABINDEX,
- PPROPINFO_STD_TABSTOP,
- PPROPINFO_STD_TAG,
- ofsPPropInfo(@Property_AutoBeep),
- 0
- );
-
- {//---------------------------------------------------------------------------
- // Event Procedure Parameter Profiles
- //---------------------------------------------------------------------------}
- type
- TParams = record
- ClickString: HLStr;
- Index: Pointer; {// Reserve space for index parameter to array ctl}
- end;
-
- {//---------------------------------------------------------------------------
- // Event list
- //---------------------------------------------------------------------------
- // Define the consecutive indicies for the events
- //---------------------------------------------------------------------------}
- const
- EVENT_PUSH_CLICK = 0;
- EVENT_PUSH_DRAGDROP = 1;
- EVENT_PUSH_DRAGOVER = 2;
- EVENT_PUSH_GOTFOCUS = 3;
- EVENT_PUSH_KEYDOWN = 4;
- EVENT_PUSH_KEYPRESS = 5;
- EVENT_PUSH_KEYUP = 6;
- EVENT_PUSH_LOSTFOCUS = 7;
-
- {//---------------------------------------------------------------------------
- // Event procedure parameter prototypes
- //---------------------------------------------------------------------------}
- Parms_SD: array[0..0]of word = (ET_SD); {// 1 x SD parm}
-
- EventClickName: array[0..8] of Char = 'Click'#0;
- EventClickParm: array[0..24] of char = 'ButtonCaption as String'#0;
-
- Event_Click: tEVENTINFO = (
- npszName: tOffset(@EventClickName);
- cParms: 1;
- cwParms: 2;
- npParmTypes: tOffset(@Parms_SD);
- npszParmProf: tOffSet(@EventClickParm);
- fl: 0
- );
-
- EventListPush: array[0..8]of ofsPEVENTInfo = (
- ofsPEventInfo(@Event_Click),
- PEVENTINFO_STD_DRAGDROP,
- PEVENTINFO_STD_DRAGOVER,
- PEVENTINFO_STD_GOTFOCUS,
- PEVENTINFO_STD_KEYDOWN,
- PEVENTINFO_STD_KEYPRESS,
- PEVENTINFO_STD_KEYUP,
- PEVENTINFO_STD_LOSTFOCUS,
- 0
- );
-
- {//---------------------------------------------------------------------------
- // Control Procedure
- // This routine is called for all VB and Windows Msgs.
- //---------------------------------------------------------------------------}
- function PushCtlProc(Control: HCtl; Wnd: HWnd;
- Msg, WParam: Word; LParam: LongInt):LongInt; export;
- var
- Params: TParams;
- StrBuf: array[0..19]of char;
- Caption: Integer;
- error: Err;
- tmpStr: PChar;
- Push: PPush;
- begin
- Push := PPush(VBDerefControl(Control));
-
- case Msg of
- VBM_MNEMONIC,
- VBN_COMMAND: begin
- if Msg = VBM_MNEMONIC then
- {// Act like a click}
- LParam := MAKELONG(0,BN_CLICKED);
- case HIWORD(LParam) of
- BN_CLICKED: begin
- Caption := GetWindowText(Wnd, StrBuf, 20);
- Params.ClickString := VBCreateHlstr(@StrBuf, Caption);
- if Push^.AutoBeep then
- Messagebeep(0);
- error := VBFireEvent(Control, EVENT_Push_Click, @Params);
- VBDestroyHlstr(Params.ClickString);
- end;
- end;
- PushCtlProc := 0;
- exit;
- end;
-
- VBM_SETPROPERTY:
- case WParam of
- IPROP_PUSH_CAPTION:
- {// To avoid a Windows problem, make sure text is
- // under 255 bytes:}
- if (lstrlen(PChar(LParam)) > 255) then
- PChar(LParam)[255] := #0;
- end;
-
- end;
-
- {// Default processing:}
- PushCtlProc := VBDefControlProc(Control, Wnd, Msg, WParam, LParam);
-
- end;
-
- {//---------------------------------------------------------------------------
- // Model struct
- //---------------------------------------------------------------------------
- // Define the control model (using the event and property structures).
- //---------------------------------------------------------------------------}
- const
- ModelDefCtlName: array[0..8] of Char = 'PasPush'#0; { default control name prefix}
- ModelClassName: array[0..14] of Char = 'PasPushButton'#0;{ Visual Basic class name}
- ModelParentClassName: array[0..8] of Char = 'Button'#0; { Parent window class if subclassed}
- modelPush: TMODEL = (
- usVersion: VB_VERSION; { VB version used by control}
- fl: MODEL_fFocusOk or MODEL_fMnemonic; { Bitfield structure}
- ctlproc: TFarProc(@PushCtlProc); { The control proc.}
- fsClassStyle: cs_VRedraw or cs_HRedraw; { window class style}
- flWndStyle: BS_PUSHBUTTON; { default window style}
- cbCtlExtra: sizeof(TPush); { # bytes alloc'd for HCTL structure}
- idBmpPalette: IDBMP_Push; { BITMAP id for tool palette}
- DefCtlName: tOffset(@ModelDefCtlName); { default control name prefix}
- ClassName: tOffset(@ModelClassName); { Visual Basic class name}
- ParentClassName: tOffset(@ModelParentClassName); { Parent window class if subclassed}
- proplist: ofs(PropListPush) ; { Property list}
- eventlist: ofs(EventListPush); { Event list}
- nDefProp: 0; { index of default property}
- nDefEvent: 0 { index of default event}
- );
-
- {//---------------------------------------------------------------------------
- // Register custom control.
- // This routine is called by VB when the custom control DLL is
- // loaded for use.
- //---------------------------------------------------------------------------}
- function VBINITCC(usVersion: Word; fRunTime: Boolean): Boolean; export;
- begin
- VBINITCC := VBRegisterModel(HInstance, modelPush);
- end;
-
- exports
- VBINITCC index 2,
- PushCtlProc index 3;
-
- begin
-
- end.
-